<?php


namespace app\backend\controller;


use app\base\controller\AdminBaseController;
use app\common\model\UserDistribution;
use think\facade\Request;

class User extends AdminBaseController
{
    public function  index(){
        $name = Request::param('name','');
        $phone = Request::param('phone','');
        $platform = Request::param('platform',0);

        $where = [];

        if(!empty($name)){
            array_push($where,['nickname','like','%'.urlencode($name).'%']);
        }
        if(!empty($phone)){
            array_push($where,['user_phone','like','%'.$phone.'%']);
        }
        if(!empty($platform)){
            array_push($where,['platform','=',$platform]);
        }

        $topicList = \app\common\model\User::where($where)
            ->order(['user_id'=>'desc'])->paginate(15,false,[
                'query'=>['name'=>$name,'phone'=>$phone,'platform'=>$platform]
            ]);

        if($topicList != null){
            foreach ($topicList as  &$v){
                $v['nickname'] = urldecode($v['nickname']);
            }
        }
        $this->assign('platform',$platform);
        $this->assign('name',$name);
        $this->assign('phone',$phone);
        $this->assign('list',$topicList);
        $this->assign('page',$topicList->render());
        return $this->fetch();
    }


}